package com.infowarelab.javatest.impl

import com.infowarelab.javatest.*
import com.infowarelab.javatest.impl.*
import org.jmock.Expectations;
import org.jmock.Mockery;

class TestComputerService extends GroovyTestCase {
	def context,computerFactory, service

    protected void setUp() throws Exception {
		context = new Mockery()
		computerFactory = context.mock(ComputerFactory.class)
        service = new ComputerServiceImpl()
        service.setComputerFactory(computerFactory)
    }

	void testUse() {
		final Computer c = new Computer("1","Acer")
		def e=new Expectations()
		e.one(computerFactory).produceComputer("Dell")
		e.will(e.returnValue(c))
		context.checking(e);
		assertEquals service.useDellComputer(), "Acer"
	}
}